package com.puhui.education.util;

import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;

import com.puhui.education.application.BaseApplication;

/**
 * Created by Administrator on 2016/6/21.
 */
public class SpannableUtil {
    public static SpannableStringBuilder createSpannable(String text, int start, int end, int textSize, int color) {
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
        spannableStringBuilder.setSpan(new AbsoluteSizeSpan(textSize), start, end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(BaseApplication.getContext().getResources().getColor(color)), start, end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        return spannableStringBuilder;
    }

    public static SpannableStringBuilder createSpannable(String text, int start, int end, int color) {
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(BaseApplication.getContext().getResources().getColor(color)), start, end,Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        return spannableStringBuilder;
    }
}
